cmake_minimum_required(VERSION 3.10)

# Configure by yourself
project(Tianqi VERSION 0.1.2 LANGUAGES CXX)
set(EXECUTABLE_NAME tianqi)

set(CMAKE_CXX_STANDARD 23)
#set(CMAKE_PREFIX_PATH "your/cmake/prefix/path")
set(QT_VERSION 5)
configure_file(TianqiConfig.h.in tianqiconfig.h)

# Required Qt Libraries
set(REQUIRED_LIBS Core Gui Widgets Network Svg)
if (${QT_VERSION} GREATER_EQUAL 6)
    set(REQUIRED_LIBS ${REQUIRED_LIBS} SvgWidgets)
endif ()
foreach (R_LIB ${REQUIRED_LIBS})
    set(REQUIRED_LIBS_QUALIFIED ${REQUIRED_LIBS_QUALIFIED} Qt${QT_VERSION}::${R_LIB})
endforeach (R_LIB)

# Target directory
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/bin")

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# Find package
find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Project sources
set(PROJECT_SOURCES Tianqi.qrc
        main.cpp
        mainwindow.cpp mainwindow.h mainwindow.ui
        tianqidata.h tianqidata.cpp
        tianqiaccesser.cpp tianqiaccesser.h
        mainprocess.cpp mainprocess.h
        settingswidget.cpp settingswidget.h settingswidget.ui)

if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
    set(PROJECT_SOURCES WIN32 ${PROJECT_SOURCES})
endif ()

add_executable(${EXECUTABLE_NAME} ${PROJECT_SOURCES})
target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${REQUIRED_LIBS_QUALIFIED})
target_include_directories(${EXECUTABLE_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
